﻿/************************************************
 * Copyright (C) 2011 东北农业大学(NEAU)
 * 版权所有。
 * 文件名：StockRoomStuffList.aspx.cs
 * 版本号：v1.0
 * 文件功能描述：材料管理信息显示
 * 作者：侯建
 * 创建日期：2011.04.18
************************************************/
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jxym.DBUtility;
using Jxym.Common.JSON;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Jxym.wlkc2011.Module.Default.server.StockRoomStuff
{
    public partial class StockRoomStuffList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Params["limit"] != null && Request.Params["start"] != null)
                {
                    if (Request.Params["ClassId"] != null)
                    {
                        int classid = Convert.ToInt32(Request.Params["ClassId"]);
                        MsSqlDal<model.StockRoomStuff> iNotice = new MsSqlDal<model.StockRoomStuff>();
                        IList<model.StockRoomStuff> List = iNotice.GetPageList("PurchaseType = " + classid, null, Convert.ToInt32(Request.Params["start"]), Convert.ToInt32(Request.Params["limit"]));
                        PageBean pb = new PageBean();
                        pb.Count = iNotice.GetPageCount("PurchaseType = " + classid, null);
                        pb.List = List;
                        Response.Write(JsonConvert.SerializeObject(pb, new JavaScriptDateTimeConverter()));
                    }
                    else
                    {
                        MsSqlDal<model.StockRoomStuff> iNotice = new MsSqlDal<model.StockRoomStuff>();
                        IList<model.StockRoomStuff> List = iNotice.GetPageList("", null, Convert.ToInt32(Request.Params["start"]), Convert.ToInt32(Request.Params["limit"]));
                        PageBean pb = new PageBean();
                        pb.Count = iNotice.GetPageCount("", null);
                        pb.List = List;
                        Response.Write(JsonConvert.SerializeObject(pb, new JavaScriptDateTimeConverter()));
                    }
                }
                else
                {
                    Response.Write("{'Count':0,'List':[]}");
                }
            }
        }
    }
}